package qldc.pm.tiensu.searchcontainer.util.bienbanbangiao;

import qldc.pm.tiensu.model.BienBanBanGiaoHoSo;

import com.liferay.portal.kernel.util.OrderByComparator;

public class BienBanBanGiaoNguoiLapComparator extends OrderByComparator {
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	private final boolean _asc;

	public static String ORDER_BY_ASC = "nguoiLap ASC";
	public static String ORDER_BY_DESC = "nguoiLap DESC";

	public BienBanBanGiaoNguoiLapComparator() {
		this(false);
	}

	public BienBanBanGiaoNguoiLapComparator(boolean orderByAsc) {
		_asc = orderByAsc;
	}

	@Override
	public int compare(Object obj1, Object obj2) {
		BienBanBanGiaoHoSo bienBanBanGiaoHoSo1 = (BienBanBanGiaoHoSo) obj1;
		BienBanBanGiaoHoSo bienBanBanGiaoHoSo2 = (BienBanBanGiaoHoSo) obj2;

		int value = bienBanBanGiaoHoSo1.getNguoiLap().compareTo(bienBanBanGiaoHoSo2.getNguoiLap());

		if (this.equals(_asc)) {
			return value;
		} else {
			return -value;
		}
	}

	public String getOrderBy() {
		if (_asc) {
			return ORDER_BY_ASC;
		} else {
			return ORDER_BY_DESC;
		}
	}
}
